<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>
<body>
    <h1 id="show"></h1>
</body>
</html>
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
<script>
    /**
 * @param {string[]} strs
 * @return {string[][]}
 */
 var groupAnagrams = function(strs) {
    if (strs.length === 1 && strs[0] === "") {
        return [[""]];
    }
    const myMap = new Map();
    for (let i = 0; i < strs.length; i++) {
        let sortedStr = strs[i].split('').sort().join('');
        if (myMap.has(sortedStr)) {
            myMap.get(sortedStr).push(strs[i]);
        } else {
            myMap.set(sortedStr, [strs[i]]);
        }
    }
    return Array.from(myMap.values())
};
const strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
const strs2 = ["eat", "tea", "tan", "ate", "nat", "bat"]
const a = [...groupAnagrams(strs)]
console.log(groupAnagrams(strs));
document.getElementById("show").innerHTML = a; 
console.log(Array.isArray(strs))
console.log('--------------------')
console.log(_.isEqual(strs,strs2))
// const str = 'helloworld'
// console.log(str.split('').sort().join(''))
</script>